<?php
/*========================================= JooSam =========================================/
/																							/
/	Extention:		JooSam																	/
/	Created by:		ScriptPlanet.eu															/
/	Site:			http://www.scriptplanet.eu												/
/	Email:			support@scriptplanet.eu													/
/	Support:		http://www.scriptplanet.eu/support										/
/	Copyright:		2011 (c) ScriptPlanet.eu												/
/	License:		CC BY-NC-ND 3.0 ~ http://creativecommons.org/licenses/by-nc-nd/3.0/		/
/	File Version:	0001																	/
/																							/
/========================================== JooSam ========================================*/
// Joomla Security
defined('_JEXEC') or die;
JHtml::_('behavior.tooltip');

$name_client = JRequest::getVar('clientName');
$msg_client = JRequest::getVar('clientMsg');
$reqID = JRequest::getVar('reqid');

$homeurl = JRoute::_('index.php?option=com_joosam');

?>

<script>
	$(function(){ $( "#jspSearch" ).autocomplete({ source: function( request, response ){ $.ajax({ url: "<?php echo JRoute::_('?option=com_joosam&view=data&layout=ajax&format=raw'); ?>", data:{ term: request.term }, success: function(data){ response( $.map( data, function(item){ return{ label: item.artist + ", " + item.title, hiddeninfo: item.songid, value: item.artist } })); } }); }, minLength: 3, select: function(event, ui){ document.getElementById('sptype').value = 'spsearch'; document.getElementById('spstring').value = ui.item.hiddeninfo; document.jmainform.submit(); } }); });
	function spletter(strng){ document.getElementById('sptype').value = 'spletter'; document.getElementById('spstring').value = strng; document.jmainform.submit(); }
</script>

<style type="text/css">
.spbutton{
	overflow:hidden;
	text-align:center;
	width:20px;
	margin:0;
	padding:0;
}
#spLetterfrm{
	text-align:center;
	margin:10px 0 0 0;
	padding:0;
}
.spHeader{
	background:#3c3c3c;
	border-radius:10px;
	padding:8px;
}
.spReqDoneMsg,
.spSongInfo{
	text-align:center;
	padding:8px;
	border-radius:10px;
	background:#3c3c3c;
	margin:10px 0 0 0;
}
.spSongInfo h4{
	margin:2px;
	padding:2px 0 10px 0;
}
.spExtrInfo{
	vertical-align:top;
	padding:0;
}
.spSongInfo2{
	border: 1px solid #969696;
	border-radius:10px;
	padding:10px;
	margin:5px;
}
.spSongTD1{
	text-align:right;
	font-weight:bold;
	padding:0 6px 0 0;
}
.spSongTD2{
	text-align:left;
}
</style>

<div class="jsam_com_main">
	<form name="jmainform" id="jmainform" action="<?php echo JRoute::_('index.php?view=joosam&layout=songinfo');?>" method="post">
		<div class="spHeader">
			<div id="spSearchfrm">
				<div class="ui-widget">
					<label for="jspSearch"><?php echo JText::_('COM_JOOSAM_COM_REQUEST_SEARCH'); ?></label>
					<input id="jspSearch" style="border-radius:4px;"/>
				</div>
			</div>
			<div id="spLetterfrm">
				<button class="spbutton" onclick="spletter('nolet');">#</button>
				<?php foreach(range('A','Z') as $letter): ?>
				<button class="spbutton" onclick="spletter('<?php echo $letter; ?>');"><?php echo $letter; ?></button>
				<?php endforeach; ?>
			</div>
			<input type="hidden" id="sptype" name="sptype" value=""/>
			<input type="hidden" id="spstring" name="spstring" value=""/>
		</div>
	</form>
	<div class="spSongInfo"><?php
		if($this->addmsg == 'done'): ?>
		<div>
			<?php 
				echo JText::_('COM_JOOSAM_THANKS');
				echo $name_client.'.';
				echo JText::_('COM_JOOSAM_REQUEST_THANKS_MSG'); ?>
		</div>
		<?php endif; 
		if($this->addmsg != 'done'): ?>
		<div>
			<?php echo JText::_('COM_JOOSAM_REQUEST_THANKS_MSG_ERROR'); ?>
		</div>
		<?php endif; ?>
		<div id="buttons">
			<button style="margin: 10px auto 0 auto;" onclick="spgoback(); return false;" id="spjback"><?php echo JText::_('COM_JOOSAM_GO_BACK'); ?></button>
		</div>
	</div>
</div>
<script>
	function spgoback(){
		 window.location="<?php echo $homeurl; ?>";
	}
</script>